/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 23735
 * Date: 2022-11-17
 * Time: 20:45
 */
public class Solution {
    public int maxArea(int[] height) {
        int max=0;
        int left=0;
        int right=height.length-1;
        while(left<right){
            int leftValue=height[left];
            int rightValue=height[right];
            int min=leftValue<rightValue?leftValue:rightValue;//取较小值
            int size=(right-left)*min;
            if(size>max){
                //更新最大值
                max=size;
            }
            //移动指针
            if(leftValue<rightValue){
                left++;
            }else{
                right--;
            }
        }
        return max;
    }
}